package com.vitabuybuy.tv.network

import com.library.common.net.NetUrl
import com.vitabuybuy.tv.dto.FieldLabelDto
import com.vitabuybuy.tv.dto.TalentUserInfoDto
import rxhttp.IAwait
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse
import java.util.*

object ApplyTalentRepository {

    fun getFieldLabelList(): IAwait<MutableList<FieldLabelDto>> {
        return RxHttp.postJson(NetUrl.api_get_field_lable_list)
            .add(
                "pageable", mapOf(
                    Pair("page", 1),
                    Pair("size", 100),
                    Pair("desc", "id")
                )
            )
            .toResponse()
    }

    fun applyTalent(params: HashMap<String, Any>): IAwait<String> {
        return RxHttp.postJson(NetUrl.api_apply_talent).addAll(params).toResponse()
    }

    fun updateTalent(params: HashMap<String, Any>): IAwait<String> {
        return RxHttp.postJson(NetUrl.api_update_talen_user_info).addAll(params).toResponse()
    }

    fun applyTalentUserInfo(): IAwait<TalentUserInfoDto> {
        return RxHttp.postJson(NetUrl.api_get_apply_talent_userinfo).toResponse()
    }


    fun resetCase(id: Int?, content: String, caseImage: String): IAwait<String> {
        val params = mapOf(
            Pair("id", id),
            Pair("content", content),
            Pair("image", caseImage)
        )
        return RxHttp.postJson(NetUrl.api_update_case)
            .add("experience", params).toResponse()
    }

    fun addCase(content: String, caseImage: String): IAwait<String> {
        val params = mapOf(
            Pair("content", content),
            Pair("image", caseImage)
        )
        return RxHttp.postJson(NetUrl.api_add_new_case)
            .add("experience", params).toResponse()
    }

    fun deleteCase(id: Int): IAwait<String> {
        return RxHttp.postJson(NetUrl.api_delete_case)
            .add("id", id).toResponse()
    }
}
